<template>
  <view class="info">
    <view class="user">
      <image class="avatar" :src="userInfo.avatar" />
      <view>
        <view class="name">{{ userInfo.username }}</view>
        <view class="quantity-box">
          <text class="quantity">量子计算机配额 {{ state.quantity }}</text>
          <button open-type="share">
            邀请好友得配额
            <image
              src="https://images-cloud.qboson.com/miniProgram/icon_share.png"
            />
          </button>
        </view>
      </view>
    </view>
    <view class="hr"></view>
    <view class="countbox">
      <view>
        <text>机算获得新可行解</text>
        <text class="count">{{ state.machine_count }}</text>
      </view>
      <view>
        <text>手算获得新可行解</text>
        <text class="count">{{ state.turn_count }}</text>
      </view>
      <view>
        <text>机算全部次数</text>
        <text class="count">{{ state.machine_total }}</text>
      </view>
      <view>
        <text>手算全部次数</text>
        <text class="count">{{ state.manual_move_count }}</text>
      </view>
    </view>
  </view>
</template>

<script setup lang="ts">
import { useUserStore } from "@/stores";
import state from "../useState";

const { userInfo } = useUserStore();
</script>

<style scoped lang="scss">
.info {
  height: 154px;
  margin: 16px;
  padding: 16px;
  box-sizing: border-box;
  border-radius: 20px;
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.4) 0%,
    #ffffff 100%
  );

  .user {
    display: flex;
    align-items: center;
    .avatar {
      width: 48px;
      height: 48px;
      margin-right: 8px;
      border-radius: 24px;
      box-sizing: border-box;
      border: 1px solid #ffffff;
    }
    .name {
      font-size: 14px;
      font-weight: 500;
      line-height: 100%;
      color: rgba(0, 0, 0, 0.9);
    }
    .quantity-box {
      display: flex;
      align-items: center;
      height: 12px;
      margin-top: 10px;
      .quantity {
        margin-right: 10px;
        font-size: 12px;
        line-height: 100%;
        color: rgba(0, 0, 0, 0.6);
      }
      button {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 4px;
        width: 113px;
        height: 24px;
        padding: 0;
        border-radius: 171px;
        background: #f35645;
        font-size: 11px;
        line-height: 100%;
        color: rgba(255, 255, 255, 0.95);
        image {
          width: 16px;
          height: 16px;
        }
      }
    }
  }

  .hr {
    margin: 15px 0;
    height: 1px;
    background-color: #fff;
  }

  .countbox {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px 0px;
    font-size: 12px;
    line-height: 100%;
    color: rgba(0, 0, 0, 0.6);
    .count {
      margin-left: 8px;
      font-size: 18px;
      font-weight: 800;
      line-height: 100%;
      color: rgba(0, 0, 0, 0.9);
    }
  }
}
</style>
